import java.util.Arrays;

/**
 * 遍历数组
 * @author zhouzhiheng98@foxmail.com 2020-07-20 16:35:07
 */
public class PrintArray {

    private static int[] ns = {1, 1, 2, 3, 5, 8 };

    public static void main(String[] args) {
        //直接打印数组-->[I@1b6d3586
        directPrint();

        //循环打印数组-->112358
        print();

        //使用toString方法-->[1, 1, 2, 3, 5, 8]
        toStringPrint();

        //倒序打印
        reversePrint();
    }

    public static void directPrint() {
        System.out.println(ns);
    }

    public static void print() {
        for (int n : ns){
            System.out.println(n);
        }
    }

    public static void toStringPrint() {
        System.out.println(Arrays.toString(ns));
    }

    public static void reversePrint() {
        for (int i = (ns.length-1);i >=0; i--) {
            System.out.println(ns[i]);
        }
    }
}
